package com.my.study.config.hook.application;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * <p>容器刷新完成扩展点</p>
 *
 * 这个扩展和SpringBoot的CommandLineRunner接口的扩展类似，
 * 只不过接受的参数是一个ApplicationArguments类，对控制台输入的参数提供了更好的封装，以--开头的被视为带选项的参数，否则是普通的参数
 *
 * @author: yidujun
 * @create: 2021/04/02 14:37
 */
@Component
@Slf4j
public class AppStartupRunner implements ApplicationRunner {
    private static int counter;
    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.info("AppStartupRunner -> Application started with option names : {}", args.getOptionNames());
        log.info("AppStartupRunner -> Increment counte counter={}", counter++);
    }
}
